﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList2.Items.Add("福建");
                DropDownList2.Items.Add("广东");
                DropDownList2.Items.Add("广西");
                DropDownList3.Items.Add("龙岩");
                DropDownList3.Items.Add("厦门");
                DropDownList3.Items.Add("漳州");
            }
        }
        protected void DropDownList2_SelectedIndexChanged1(object sender, EventArgs e)
        {
            string province = DropDownList2.SelectedValue;
            DropDownList3.Items.Clear();
            if (province == "福建")
            {
                DropDownList3.Items.Add("龙岩");
                DropDownList3.Items.Add("厦门");
                DropDownList3.Items.Add("漳州");
            }
            else if (province == "广东")
            {
                DropDownList3.Items.Add("深圳");
                DropDownList3.Items.Add("广州");
                DropDownList3.Items.Add("东莞");
            }
            else
            {
                DropDownList3.Items.Add("南宁");
                DropDownList3.Items.Add("桂林");
                DropDownList3.Items.Add("柳州");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string AHO = "爱好是：";
            string XIN = "性别是：";
            foreach (ListItem item in RadioButtonList1.Items)
            {
                if (item.Selected)
                {
                    XIN = $"{item.Text}";
                }
                else
                {
                    XIN += "人妖";
                    break;
                }
            }
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected)
                {
                    AHO += CheckBoxList1.Items[i].Text + "   ";
                }
                else
                {
                    AHO = "没有爱好";
                }
            }
            if (FileUpload1.HasFile)
            {
                string fileName = FileUpload1.FileName;
                if (fileName.EndsWith(".jpg") || fileName.EndsWith(".png") || fileName.EndsWith(".jpeg"))
                {
                    string url = Server.MapPath("/imd/" + fileName);
                    FileUpload1.SaveAs(url);
                    Image1.ImageUrl = "/imd/" + fileName;
                    Image1.Visible = true;
                }
            }
            Label1.Text = $"用户名：{TextBox1.Text} 密码：{TextBox2.Text} {XIN} {AHO} 籍贯：{DropDownList2.Text}省{DropDownList3.Text}市 其他信息{TextBox3.Text} 头像：";
        }
    }
}